// pages/toOrder/toOrder.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    anchorsInfo:{
      avatarSrc:'http://img0.imgtn.bdimg.com/it/u=2528075055,1959623095&fm=27&gp=0.jpg',
      name:'确认过眼神'
    },
    categorys:['绝地求生','王者荣耀','情感陪伴','情感发泄',],
    coupons:['1元','2元'],
    coupon:'',
    categoryName:'',
    time:'12:01',
    orderNum:1,
    noteValue:'',
    total:0,
    plusIcon:'https://bpic.588ku.com/element_pic/01/37/81/49573c62ab5cd23.jpg!/fw/254/quality/90/unsharp/true/compress/true',
    reduceIcon:'https://bpic.588ku.com/element_pic/00/96/18/3456f2f90547762.jpg!/fw/254/quality/90/unsharp/true/compress/true',
    arrowSrc:'https://bpic.588ku.com/element_pic/00/96/10/4456f2f6f075d88.jpg!/fw/254/quality/90/unsharp/true/compress/true'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  bindPickerChange(e){
    let index = e.detail.value;
    let categoryName = this.data.categorys.find((item,ind)=>ind==index);
    this.setData({ categoryName});
  },
  bindCouponsChange(e) {
    let index = e.detail.value;
    let coupon = this.data.coupons.find((item, ind) => ind == index);
    this.setData({ coupon });
  },

  bindTimeChange: function (e) {
    this.setData({
      time: e.detail.value
    })
  },

  plusOrderNum(){
    let orderNum = this.data.orderNum;
    orderNum++;
    this.setData({
      orderNum,
    })
  },

  reduceOrderNum() {
    let orderNum = this.data.orderNum;
    if (orderNum===1){
        return;
    }else{
        orderNum--;
        this.setData({
          orderNum,
        })
    }
    
  },

  setNoteValue(e){
    this.setData({
      noteValue: e.detail.value
    })
  },

  toOrderDetail(){
    wx.navigateTo({
      url:'../orderDetail/orderDetail',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})